package com.xltt.bluetoothlib.ble.Exception;

import java.io.Serializable;


public abstract class BleException implements Serializable {

    private static final long serialVersionUID = 8004414918500865564L;

    public static final byte success = 0x00;//成功
    public static final byte cmd_error = 0x01;//指令码不支持
    public static final byte parameter_error = 0x02;//参数错误
    public static final byte data_length_error = 0x03;//可变数据域长度错误
    public static final byte fomat_error = 0x04;//帧格式错误
    public static final byte lrc_error = 0x05;//LRC校验失败
    public static final byte other_error = 0x06;//其他
    public static final byte timeout = 0x07;//超时
    public static final byte network_connect_error = 0x08;//网络未连接

    public static final int ERROR_CODE_TIMEOUT = 100;
    public static final int ERROR_CODE_GATT = 101;
    public static final int ERROR_CODE_OTHER = 102;

    private int code;
    private String description;

    public BleException(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public BleException setCode(int code) {
        this.code = code;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public BleException setDescription(String description) {
        this.description = description;
        return this;
    }

    @Override
    public String toString() {
        return "BleException { " +
               "code=" + code +
               ", description='" + description + '\'' +
               '}';
    }
}
